package cn.johnyu.account.mapper;

import cn.johnyu.commons.dto.AccountDto;
import org.apache.ibatis.annotations.*;

@Mapper
public interface AccountMapper {
    @Select("select * from accounts where id = #{id}")
    AccountDto loadAccount(@Param("id") int id);
    @Insert("insert into accounts (name,balance) values (#{name},#{balance})")
    int addAccount(AccountDto dto);

    @Update("update accounts set balance= balance - #{amount} where id = #{id}")
    int reduceBalance(@Param("id") int id,@Param("amount") int amount);
}
